package com.yc.txx.vo;



//code = 1 ，msg = "ok" ,data=[1,2]

/**
 *           JSON 格式
 *         {code：1 ,msg='ok',data:[1,2]}
 */
public class Result {
    //结果码 0失败  ，1成功
    int code;

    //结果描述信息
    String msg;

    //数据
    Object data;

    public Result(int code,String msg,Object data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result success(String msg,Object data){
        return new Result(1, msg, data);
    }

    public static Result success(String msg){
        return new Result(1, msg, null);
    }

    public static Result failure(String msg,Object data){
        return new Result(0, msg, data);
    }

    public static Result failure(String msg){
        return new Result(0, msg, null);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}